module ProposalsHelper

  def render_proposal_table proposals, title
    render :partial => "proposals_table", :locals => {:proposals => proposals, :title => title}
  end

  def get_colored_role_string proposal, jurisdiction
    return ""
    if proposal.workflow_state == "awaiting_approval"
      roles = Role.all
      result = "".html_safe
      roles.each do |role|
        underline = "text-decoration:underline;" if current_user.is_responsible_for role, jurisdiction
        if proposal.approval_for(role, jurisdiction)
          result = "#{result} #{content_tag(:span, role.name, style("green", underline))}"
        else
          result = "#{result} #{content_tag(:span, role.name, style("red", underline))}"
        end
      end
      return result
    else
      return ""
    end
  end

  def style color, underline
    {:style => "padding: 0 4 0 4; background-color: white; color: #{color}; font-size: xx-small; #{underline}"}
  end

  def get_responsibles_string jurisdictionMembers
    jurisdictionMembers.collect{|jm| jm.user.gpn}.join(", ")
  end
  
end
